package com.simple.util.common;

import org.apache.cxf.jaxws.JaxWsProxyFactoryBean;
import org.apache.log4j.Logger;

import com.simple.datax.service.ResentService;
import com.simple.util.common.SimplePropertyLoad;
import com.simple.util.exception.SimpleSystemException;

public class ResentMessageServiceUtil {
	private static String RESENT_MESSAGE_SERVER_URL;
	
	private static final Logger LOG = Logger.getLogger(ResentMessageServiceUtil.class);
	
	ResentMessageServiceUtil(){
		RESENT_MESSAGE_SERVER_URL = SimplePropertyLoad.getInstance().getString("resent.message.web.service.server.url");
	}
	
	public static boolean resetProcess(final String id) throws SimpleSystemException{
		boolean result = false;
		try{
			JaxWsProxyFactoryBean factory = new JaxWsProxyFactoryBean();  
	        factory.setServiceClass(ResentService.class);  
	        factory.setAddress(RESENT_MESSAGE_SERVER_URL+"/com.simple.datax.service.ResentService?wsdl");
	        
	        ResentService rs = (ResentService)factory.create();
	        
	        result = rs.resentws(id);
		}catch(Exception e){
			LOG.error("Resent Process Web Service error");
			throw new SimpleSystemException("message.system.error.connect.resentmessage.server", e);
		}
		
		return result;
	}
	
}
